<template>
  <div>
     <h3>黑店里的神秘黑影</h3>
     <XiaoHei v-for="item in list" :key="item.id" 
     :id="item.id"
     :proname="item.proname"
     :proprice="item.proprice"
     :desc="item.desc"
     @mm='nn'
     ></XiaoHei>
   </div>
</template>
 
<script>
import XiaoHei from './XiaoHei.vue'
export default {
  name: "DaHei",
  components: {
    XiaoHei
  },
  props: {},
  data() {
    return {
      list: [
        {
          id: 1,
          proname: '超级好吃棒棒糖',
          proprice: 188,
          low: 160,
          desc: '甜'
        },
        {
          id: 2,
          proname: '超级好吃的大鸡腿',
          proprice: 360,
          low: 320,
          desc: '香'
        },
        { id: 3, proname: '超级无敌冰激凌', proprice: 42, low: 30, desc: '冰' }
      ]
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    nn(id,num){
      // console.log(id);
      this.list.forEach(item =>{
        if(item.id === id){
          item.proprice > item.low
          ? item.proprice -=num
          : alert('不要再砍了')
        }
      })
    }
  }
};
</script>

<style scoped>
     
</style>